<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>众筹主题</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../include/commonFile.jsp" %>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/crowdfundMultiple/event/list.do" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo" value="${page.page}"/>
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">主题名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="name" autocomplete="off" class="layui-input"
                                           value="${event.name}" placeholder="请输入主题名称">
                                </div>
                            </li>
                            <li class="form-item-inline"><label class="search-form-lable">主题状态</label>
                                <div class="layui-input-inline">
                                    <select name="progress">
                                        <option value="">全部</option>
                                        <option value="1" ${event.progress == 1 ? 'selected' : ''}>进行中</option>
                                        <option value="2" ${event.progress == 2 ? 'selected' : ''}>已截止</option>
                                    </select>
                                </div>
                            </li>
                            <li class="form-item-inline"><label class="search-form-lable">审核状态</label>
                                <div class="layui-input-inline">
                                    <select name="checkStatus">
                                        <option value="">全部</option>
                                        <option value="0" ${event.checkStatus == 0 ? 'selected' : ''}>待审核</option>
                                        <option value="1" ${event.checkStatus == 1 ? 'selected' : ''}>审核通过</option>
                                        <option value="2" ${event.checkStatus == 2 ? 'selected' : ''}>已拒绝</option>
                                    </select>
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger"
                                       href="javascript:submitFunction('#myForm')">查询</a>
                                    <a class="layui-btn layui-btn-normal"
                                       href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">发布时间</label>
                                <div class="check-btn-inner" id="timeType">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                    <input type="hidden" name="timeType" value="${input.timeType}"/>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createStart" value="${input.createStart}" placeholder="开始日">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createEnd" value="${input.createEnd}" placeholder="截止日">
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="list-content">
                <ul class="num mt10">
                    <div class="l">
                        <li class="f16">共<span class="red">${page.totalCount}</span>条数据</li>
                    </div>
                    <p class="cl"></p>
                </ul>
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col width="75px">
                            <col width="18%">
                            <col width="10%">
                            <col width="150px">
                            <col width="115px">
                            <col width="125px">
                            <col width="125px">
                            <col width="120px">
                            <col>
                            <col>
                        </colgroup>
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>主题名称</th>
                            <th>发布者</th>
                            <th>添加时间</th>
                            <th>主题状态</th>
                            <th>众筹项目数</th>
                            <th>审核状态</th>
                            <th>添加</th>
                            <th>分析</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:set var="nowDate" value="<%=new Date()%>"></c:set>
                        <c:forEach var="event" items="${list}" varStatus="st">
                            <tr>
                                <td>${page.limit * (page.page-1) + st.count}</td>
                                <td class="ellipsis-1 tl" title=" ${event.name}">${event.name}</td>
                                <td class="table-member"
                                    onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${event.createBy}','400px','470px')">
                                    <div class="member-cell">
                                        <div class="member-logo common-img">
                                            <img src="<c:if test="${event.logo != null}">${event.logo}?imageMogr2/auto-orient/crop/126x126</c:if>"
                                                 alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1">
                                            <a class="blue" title="${event.realname}"
                                               href="javascript:void(0);">${event.realname}</a>
                                        </div>
                                    </div>
                                </td>
                                <td><fmt:formatDate value="${event.createDate}" pattern="yyyy-MM-dd HH:mm"/></td>
                                <td>
                                    <c:if test="${event.endTime > nowDate}">
                                        <span class="red">进行中</span>
                                    </c:if>
                                    <c:if test="${event.endTime < nowDate}">
                                        <span>已截止</span>
                                    </c:if>
                                </td>
                                <td>
                                    <a href="${ctx}/activity/activity/zcActivityList.do?eventId=${event.id}" target="_self">${event.crowdfundNum}</a>
                                </td>
                                <td title="${event.checkRemark}">
                                    <c:choose>
                                        <c:when test="${event.checkStatus==0}">待审核</c:when>
                                        <c:when test="${event.checkStatus==1}">
                                            <span style="color: green;">审核通过</span>
                                        </c:when>
                                        <c:when test="${event.checkStatus==2}">
                                           <span>
                                               <a href="javascript:showAuthor1('${event.checkRemark}')" class="red">
                                                   已拒绝&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                   <font style="color: #5e5e5e">▼</font>
                                               </a>
                                           </span>
                                        </c:when>
                                    </c:choose>
                                </td>
                                <td>
                                    <a href="javaScript:txz.expireCheck('', function() {
                                        publishCrowdfund('${event.checkStatus}','${ctx}/crowdfundMultiple/event/copyEvent.do?eventId=${event.id}')
                                    });">发布众筹项目</a>
                                </td>
                                <td class="tb-opts">
                                    <div class="comm-opts">
                                        <a href="${ctx}/activityMultiple/project/listForEvent.do?eventId=${event.id}">数据查看</a>
                                        <shiro:hasPermission name="crowdfund:event:analyze">
                                            <a target="_blank" href="${ctx}/activityMultiple/project/analyzeList.do?eventId=${event.id}" target="_self">数据分析</a>
                                        </shiro:hasPermission>
                                    </div>
                                </td>
                                <td class="tb-opts">
                                    <div class="comm-opts">
                                        <a href="javascript:txz.expireCheck('${ctx}/crowdfundMultiple/event/view.do?id=${event.id}')"
                                           target="_self">编辑</a>
                                        <a href="javascript:txz.deleteObject('确定要删除主题吗？', '${ctx}/crowdfund/event/delete.do?id=${event.id}');">删除</a>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div>
        <!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
    <div id="authorDialog1">
        <table class="layui-table" lay-skin="line">
            <tbody>
            <tr>
                <td class="table-member">
                    <div class="member-cell">
                        <div class="member-name ellipsis-1">

                        </div>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '众筹主题',
            curr: true
        }],
        info: '<span class="f14 gray">众筹主题指的是，可以对这个主题所关联的所有众筹项目进行管理，关联所有的众筹项目数据。</span>\n' +
            '<a href="javascript:openHelpDialog()" class="red ml10"><i class="iconfont icon-mobile"></i>手机端效果</a>\n' +
            '<a href="${ctx}/help/help/list.do?id=30986da5be0245e58ec1b410d6a062a6" class="red ml10" target="_blank"><i class="iconfont icon-book"></i>帮助教程</a>',
        btns: [{
            name: '添加主题',
            icon: 'add',
            href: '${ctx}/crowdfundMultiple/event/view.do',
            isCheckExpire: true
        }]
    });

    $(function () {
        var index = null;
        $(".over-tip").mouseover(function () {
            index = txz.openQTip(this);
        }).mouseout(function () {
            layer.close(index);
        });

        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });
        layui.use(['element', 'laydate'], function () {
            var laydate = layui.laydate;
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    })

    function openHelpDialog() {
        txz.openHelpDialog({
            title: '手机效果预览',
            describe: '众筹主题指的是，可以对这个主题所关联的所有众筹项目进行管理，关联所有的众筹项目数据。',
            detailList: [{
                text: '1/众筹项目详情',
                url: '${ctx}/image/dialog/zc_1.jpg'
            }, {
                text: '2/活动详情',
                url: '${ctx}/image/dialog/zc_2.jpg'
            }, {
                text: '3/活动信息',
                url: '${ctx}/image/dialog/zc_3.jpg'
            }]
        })
    }

    function createCircle(actId) {
        var content = "确定要生成吗？请选择生成<br/><label for='all1' class='mr10'><input type='radio' id='all1' name='type' value='2' checked='checked' >全部报名人员</label>" +
            "<label for='success'><input type='radio' id='success' name='type' value='1' >已成功报名人员</label>";
        layer.confirm(content, {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            var type = $("[name=type]:checked").val() || '2';
            layer.close(index);
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/crowdfundMultiple/event/createCircle.do", {
                eventId: actId,
                type: type
            }, function (data) {
                layer.close(loadIndex);
                setTimeout(function () {
                    if (data.success) {
                        util.layerMsgSuccess("生成成功")
                    } else {
                        util.layerMsgError("生成失败")
                    }
                });
            })
        });
    }

    function createGatherInfo(actId) {
        var content = "确定要生成吗？请选择生成<br/><label for='all1' class='mr10'><input type='radio' id='all1' name='type' value='2' checked='checked' >全部报名人员</label>" +
            "<label for='success'><input type='radio' id='success' name='type' value='1' >已成功报名人员</label>";
// 		content = "确定要生成吗？";
        layer.confirm(content, {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            var type = $("[name=type]:checked").val() || '2';
            layer.close(index);
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/crowdfundMultiple/event/createGatherInfo.do", {
                eventId: actId,
                type: type
            }, function (data) {
                layer.close(loadIndex);
                setTimeout(function () {
                    if (data.success) {
                        util.layerMsgSuccess("生成成功")
                    } else {
                        util.layerMsgError("生成失败")
                    }
                });
            })
        });
    }

    /**
     * 发布众筹项目
     * @param checkStatus
     * @param url
     */
    function publishCrowdfund(checkStatus, url) {
        if (checkStatus != 1) {
            layer.msg('审核通过后方可发布众筹项目<br/>&nbsp;&nbsp;&nbsp;&nbsp;请耐心等待平台审核', {
                icon: 0,
                title: '系统提示',
                time: 2500
            });
        } else {
            window.location.href = url;
        }
    }

    function showAuthor1(remarks) {
        var setPayIndex = layer.open({
            type: 1,
            area: '400px',
            title: '查看备注',
            content: $("#authorDialog1"),
            btn: ['关闭'],
            success: function () { // 弹出后回调
                if (remarks != null && remarks.length > 0) {
                    $("#authorDialog1").find(".member-name").text(remarks);
                } else {
                    util.layerMsgError("暂无备注");
                }
            },
            end: function () { // 销毁后回调
                $("#authorDialog1").find(".member-name").text('');
            },
            yes: function () { // 确定按钮
                layer.close(setPayIndex);
            }
        });
    }
</script>
</body>
</html>